package com.example.testproject;

import java.util.ArrayList;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.support.v4.widget.SimpleCursorAdapter.ViewBinder;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class Screen3 extends Activity implements View.OnClickListener {
	EditText name1, password1, email1, phone1;
	String name,pwd, email, phone;
	Button signup1;
	


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.screen3);
         signup1 = (Button) findViewById(R.id.login);
		
        name1 = (EditText)findViewById(R.id.name);
        password1 = (EditText)findViewById(R.id.password);
        email1 = (EditText)findViewById(R.id.email_id);
        phone1  = (EditText)findViewById(R.id.phone_no);
        

		Button puneTab01 = (Button) findViewById(R.id.puneTab01);
		Button puneTab02 = (Button) findViewById(R.id.puneTab02);
		Button puneTab03 = (Button) findViewById(R.id.puneTab03);
		Button puneTab04 = (Button) findViewById(R.id.puneTab04);
		puneTab01.setOnClickListener(this);
		puneTab02.setOnClickListener(this);
		puneTab03.setOnClickListener(this);
		puneTab04.setOnClickListener(this);
		
		signup1.setOnClickListener(this);
		
		
    }
    	 
		
		
		       
 
                	 public void onClick(View v) {
                		 
                		 name = name1.getText().toString();
          			   pwd = password1.getText().toString();
          			   email = email1.getText().toString();
          			   phone = phone1.getText().toString();

                	        switch (v.getId()) {
                	       
                	        case R.id.login:
                	        	 try{
                				        ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
                				        nameValuePairs.add(new BasicNameValuePair("email", email));
                				        nameValuePairs.add(new BasicNameValuePair("pwd", pwd));
                						nameValuePairs.add(new BasicNameValuePair("name", name));
                						nameValuePairs.add(new BasicNameValuePair("phone", phone));

                						//.d("mon", mLogon);


                						HttpClient httpclient = new DefaultHttpClient();
                						HttpPost httppost = new HttpPost("http://10.0.2.2/cubito/signup.php");
                						httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
                						HttpResponse response = httpclient.execute(httppost);
                						HttpEntity entity = response.getEntity();
                						Log.d("http", EntityUtils.toString(entity));
                						Toast.makeText(getApplicationContext(), "Location Update Sent !", Toast.LENGTH_LONG).show();
                				    	//main_intent = new Intent(getApplicationContext(), main.class);
                				    
                				    	}
                				  

                					catch(Exception e)
                						{
                							Log.d("httperror","Error in http connection "+e.toString());
                						}
                						finally
                						{
                							
                						}
                				   

                	        	 Intent intent = new Intent(/*FirstActivity.this*/ v.getContext(), Screen11.class);
                	        	 intent.putExtra("name", name);
                				   intent.putExtra("email", email);
                				   intent.putExtra("phone", phone);
                				    startActivity(intent);

                	            break;
                	                        	        case R.id.puneTab01:
                	        	Intent intent2 = new Intent(/*FirstActivity.this*/ v.getContext(), Screen1.class);
                			    startActivity(intent2);

                	            break;
                	        case R.id.puneTab02:
                	        	Intent intent3 = new Intent(/*FirstActivity.this*/ v.getContext(), Screen8.class);
                			    startActivity(intent3);

                	            break;
                	        case R.id.puneTab03:
                	        	Intent intent4 = new Intent(/*FirstActivity.this*/ v.getContext(), Screen10.class);
                			    startActivity(intent4);

                	            break;
                	        case R.id.puneTab04:
                	        	Intent intent5 = new Intent(/*FirstActivity.this*/ v.getContext(), Screen9.class);
                			    startActivity(intent5);

                	            break;


                	        default:
                	            break;
                	        }
                 }
		
    
   
}

